from flask import Flask, jsonify, request
from flask_cors import CORS
from agent.agent_manager import get_agent_response
from tts.text_to_speech import generate_audio_from_text

app = Flask(__name__)
CORS(app)


@app.route('/api', methods=['POST'])
def chat():
    user_input = request.json.get("query")
    if not user_input:
        return jsonify({"error": "无效的输入"}), 400

    # 调用代理管理器获取完整响应
    response = get_agent_response(user_input)

    return jsonify(response)


if __name__ == '__main__':
    app.run(debug=True)
